package files

import (
	"io/ioutil"
	"path/filepath"

	"gitee.com/xuender/reader/pb"
)

func (p *Service) folder(fi *pb.FileInfo) []*pb.FileInfo {
	fs, err := ioutil.ReadDir(fi.Path)
	if err != nil {
		panic(err)
	}

	infos := make([]*pb.FileInfo, len(fs))

	for i, f := range fs {
		infos[i] = p.newFileInfoByFs(f, filepath.Join(fi.Path, f.Name()))
	}

	return infos
}
